package com.firemoss.atonement.test.frameworks.magicbus
{
	import com.firemoss.atonement.frameworks.magicbus.MappingAssembler;
	import com.firemoss.atonement.mapper.Mapper;
	import com.firemoss.atonement.test.mapper.objects.Contact;
	import com.firemoss.atonement.test.mapper.objects.ContactDTO;
	
	import org.flexunit.asserts.assertTrue;
	
	public class MappingAssemblerTests
	{
		[Test]
		public function mapping_assembler_honors_simple_arguments_on_disassembly() : void
		{
			var assembler : MappingAssembler = new MappingAssembler( new Mapper(), Contact, ContactDTO )
			
			// Make sure it works with all DTOs to begin with
			var result : Array = assembler.disassemble( [ new Contact() ] );
			assertTrue( result[ 0 ] is ContactDTO )
			
			// Ok, hit it with some simple tests
			result = assembler.disassemble( [ new Contact(), true ] )
			assertTrue( result[ 0 ] is ContactDTO )
			assertTrue( result[ 1 ] == true )
			result = assembler.disassemble( [ new Contact(), 1234 ] )
			assertTrue( result[ 0 ] is ContactDTO )
			assertTrue( result[ 1 ] == 1234 )
			result = assembler.disassemble( [ new Contact(), "string" ] )
			assertTrue( result[ 0 ] is ContactDTO )
			assertTrue( result[ 1 ] == "string" )
		}
		
		private function createContact() : Contact
		{
			return new Contact({
				firstName : "John",
				lastName : "Doe"
			})
		}
					
	}
}